package com.iplant.ams.service.po.ams.fxt;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.ams.service.basicenum.ams.fxt.AMSFrockType;
import com.iplant.ams.service.po.ams.asset.AMSAssetInfo;
import com.iplant.base.po.BasePO;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.join.DBJoin;
import com.iplant.base.utils.annotation.join.multi.DBJoinMulti;
import com.iplant.base.utils.annotation.po.DBBasePO;
import com.iplant.basic.service.basicenum.bms.BMSFunctionType;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@DBBasePO(TableName = "dms_frock_ledger", Name = false, Active = false,Code = false,
        Schemas = DBSchemas.AMS, CheckName = {"AssetInfoID"}, CodeAuto = true, CodePrefix = "DFL-{yyMM}-")
public class DMSFrockLedger extends BasePO implements Serializable {
    private static final long serialVersionUID = 1L;


    @DBCondition
    @DBField
    public int AssetInfoID = 0;

    @DBCondition
    @DBField
    public int FrockToolID = 0;


    @DBCondition(CompareType = DBCondition.DBCompareType.like)

    @DBJoin(name = "Name", tableName = "ams_asset_list", tableAsName = "a1", Schemas = DBSchemas.AMS,
            MainTableField
                    = "AssetInfoID")
    public String Name = "";


    @DBCondition(CompareType = DBCondition.DBCompareType.like,ParamName2 = "CodeEQ")
    @DBJoin(name = "Code", tableName = "ams_asset_list", tableAsName = "a1", Schemas = DBSchemas.AMS,
            MainTableField
                    = "AssetInfoID")
    public String Code = "";

    @DBCondition
    @DBJoin(name = "Active", tableName = "ams_asset_list", tableAsName = "a1", Schemas = DBSchemas.AMS,
            MainTableField
                    = "AssetInfoID")
    public int Active = 0;

    /**
     * 采集编号
     **/
    @DBCondition
    @DBField
    public String AssetNo = "";

    @DBCondition
    @DBJoin(name = "StandardModelID", tableName = "ams_frocktool", tableAsName = "f1", Schemas = DBSchemas.AMS,
            MainTableField = "FrockToolID")
    public int StandardModelID = 0;//资产标准型号ID

    /**
     * 工装类型
     */
    @DBCondition
    @DBJoin(name = "FrockType", tableName = "ams_frocktool", tableAsName = "f1", Schemas = DBSchemas.AMS,
            MainTableField = "FrockToolID")
    public int FrockType = 0;

    /**
     * 工装类型文本
     */
    public String FrockTypeText = "";


    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "ams_asset_standard_model", tableAsName = "a2", JoinIndex = 2, Schemas = DBSchemas.AMS,
            ConditionalJoin = "f1.StandardModelID=a2.ID")
    public String StandardModelName = "";


    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Code", tableName = "ams_asset_standard_model", tableAsName = "a2", JoinIndex = 2, Schemas = DBSchemas.AMS,
            ConditionalJoin = "f1.StandardModelID=a2.ID")
    public String StandardModelCode = "";


    /**
     * 当前存在设备ID
     **/
    @DBCondition(CompareType = DBCondition.DBCompareType.findInSet)
    @DBField
    public List<Integer> DeviceIDList = new ArrayList<Integer>();
    /**
     * 设备名称
     **/
    @DBJoinMulti(Name = "Name", TableName = "dms_device_ledger", MainTableField = "DeviceIDList", Schemas = DBSchemas.AMS)
    public String DeviceName = "";

    @DBJoinMulti(Name = "Code", TableName = "dms_device_ledger", MainTableField = "DeviceIDList", Schemas = DBSchemas.AMS)
    public String DeviceCode = "";

    @DBField
    public int Status = 0;

    @DBField
    public String Position = "";

    /**
     * 使用班组
     */
    @DBCondition
    @DBField
    public int ClassInfoID = 0;


    /**
     * 班组对应部门ID（来源于部门）
     */
    @DBCondition
    @DBJoin(name = "DepartmentID", tableName = "bms_classinfo", tableAsName = "f2", Schemas = DBSchemas.Basic,
            MainTableField = "ClassInfoID")
    public int DepartmentID = 0;

    /**
     * 班组名称（来源于部门）
     */
    @DBCondition
    @DBJoin(name = "Name", tableName = "bms_department", tableAsName = "d1", Schemas = DBSchemas.Basic,
            ConditionalJoin = "f2.DepartmentID=d1.ID")
    public String DepartmentName = "";

    /**
     * 班组编码（来源于部门）
     */
    @DBCondition
    @DBJoin(name = "Code", tableName = "bms_department", tableAsName = "d1", Schemas = DBSchemas.Basic,
            ConditionalJoin = "f2.DepartmentID=d1.ID")
    public String DepartmentCode = "";


    /**
     * 班组职能
     */
    @DBCondition
    @DBJoin(name = "FunctionType", tableName = "bms_classinfo", tableAsName = "f2", Schemas = DBSchemas.Basic,
            MainTableField = "ClassInfoID")
    public int FunctionType = 0;

    /**
     * 班组职能（翻译）
     */
    public String FunctionTypeName = "";


    /**
     * 责任人ID
     */
    @DBField
    public int DutyPersonID = 0;
    /**
     * 责任人名称
     */
    @DBJoin(name = "Name", tableName = "mbs_user", tableAsName = "user1", Schemas = DBSchemas.Basic,
            MainTableField = "DutyPersonID")
    public String DutyPersonName = "";

    public DMSFrockLedger() {
        super();
    }


    public DMSFrockLedger(AMSAssetInfo wAMSAssetInfo, AMSFrockTool wAMSFrockTool){super();

        Name=wAMSAssetInfo.Name;
        AssetNo=wAMSAssetInfo.AssetSN;
        Code=wAMSAssetInfo.Code;
        AssetInfoID=wAMSAssetInfo.ID;
        FrockToolID=wAMSFrockTool.ID;
        StandardModelID =wAMSAssetInfo.StandardModelID;
        StandardModelName =wAMSAssetInfo.StandardModelName;
        StandardModelCode =wAMSAssetInfo.StandardModelCode;
        Position=wAMSFrockTool.Position;
        FrockType=wAMSFrockTool.FrockType;
        Active=wAMSAssetInfo.Active;
    }

    @JsonProperty("AssetInfoID")
    public int getAssetInfoID() {
        return AssetInfoID;
    }

    public void setAssetInfoID(int assetInfoID) {
        AssetInfoID = assetInfoID;
    }

    @JsonProperty("FrockToolID")
    public int getFrockToolID() {
        return FrockToolID;
    }

    public void setFrockToolID(int frockToolID) {
        FrockToolID = frockToolID;
    }

    @Override
    @JsonProperty("Name")
    public String getName() {
        return Name;
    }

    @Override
    public void setName(String name) {
        Name = name;
    }



    @JsonProperty("AssetModelID")
    public int getStandardModelID() {
        return StandardModelID;
    }

    public void setStandardModelID(int standardModelID) {
        StandardModelID = standardModelID;
    }

    @JsonProperty("FrockInfoName")
    public String getStandardModelName() {
        return StandardModelName;
    }

    public void setStandardModelName(String standardModelName) {
        StandardModelName = standardModelName;
    }

    @JsonProperty("FrockInfoCode")
    public String getStandardModelCode() {
        return StandardModelCode;
    }

    public void setStandardModelCode(String standardModelCode) {
        StandardModelCode = standardModelCode;
    }

    @JsonProperty("DeviceIDList")
    public List<Integer> getDeviceIDList() {
        return DeviceIDList;
    }

    public void setDeviceIDList(List<Integer> deviceIDList) {
        DeviceIDList = deviceIDList;
    }

    @JsonProperty("DeviceName")
    public String getDeviceName() {
        return DeviceName;
    }

    public void setDeviceName(String deviceName) {
        DeviceName = deviceName;
    }

    @JsonProperty("DeviceCode")
    public String getDeviceCode() {
        return DeviceCode;
    }

    public void setDeviceCode(String deviceCode) {
        DeviceCode = deviceCode;
    }

    @JsonProperty("Status")
    public int getStatus() {
        return Status;
    }

    public void setStatus(int status) {
        Status = status;
    }

    @JsonProperty("ClassInfoID")
    public int getClassInfoID() {
        return ClassInfoID;
    }

    public void setClassInfoID(int classInfoID) {
        ClassInfoID = classInfoID;
    }

    @JsonProperty("DepartmentID")
    public int getDepartmentID() {
        return DepartmentID;
    }

    public void setDepartmentID(int departmentID) {
        DepartmentID = departmentID;
    }

    @JsonProperty("DepartmentName")
    public String getDepartmentName() {
        return DepartmentName;
    }

    public void setDepartmentName(String departmentName) {
        DepartmentName = departmentName;
    }

    @JsonProperty("DepartmentCode")
    public String getDepartmentCode() {
        return DepartmentCode;
    }

    public void setDepartmentCode(String departmentCode) {
        DepartmentCode = departmentCode;
    }

    @JsonProperty("FunctionType")
    public int getFunctionType() {
        return FunctionType;
    }

    public void setFunctionType(int functionType) {
        FunctionType = functionType;
    }

    @JsonProperty("FunctionTypeName")
    public String getFunctionTypeName() {
        FunctionTypeName=BMSFunctionType.getEnumType(FunctionType).getLabel();
        return FunctionTypeName;
    }

    public void setFunctionTypeName(String functionTypeName) {
        FunctionTypeName = functionTypeName;
    }

    @JsonProperty("Position")
    public String getPosition() {
        return Position;
    }

    public void setPosition(String position) {
        Position = position;
    }

    @JsonProperty("DutyPersonID")
    public int getDutyPersonID() {
        return DutyPersonID;
    }

    public void setDutyPersonID(int dutyPersonID) {
        DutyPersonID = dutyPersonID;
    }

    @JsonProperty("DutyPersonName")
    public String getDutyPersonName() {
        return DutyPersonName;
    }

    public void setDutyPersonName(String dutyPersonName) {
        DutyPersonName = dutyPersonName;
    }
    @JsonProperty("FrockType")
    public int getFrockType() {
        return FrockType;
    }

    public void setFrockType(int frockType) {
        FrockType = frockType;
    }
    @JsonProperty("FrockTypeText")
    public String getFrockTypeText() {
        FrockTypeText= AMSFrockType.getEnumType(FrockType).getLabel();
        return FrockTypeText;
    }

    public void setFrockTypeText(String frockTypeText) {
        FrockTypeText = frockTypeText;
    }
    @JsonProperty("Code")
    @Override
    public String getCode() {
        return Code;
    }

    @Override
    public void setCode(String code) {
        Code = code;
    }
    @JsonProperty("AssetNo")
    public String getAssetNo() {
        return AssetNo;
    }

    public void setAssetNo(String assetNo) {
        AssetNo = assetNo;
    }

    @Override
    @JsonProperty("Active")
    public int getActive() {
        return Active;
    }

    @Override
    public void setActive(int active) {
        Active = active;
    }
}
